<template>
  <el-container class="box1">
    <el-main >
  <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" laalisabel-width="100px" class="demo-ruleForm">
    <el-form-item label="昵称" prop="uAlias">
      <el-input  v-model="ruleForm.uAlias" autocomplete="off" type="text"></el-input>
    </el-form-item>
    <el-form-item label="邮箱" prop="uMail">
      <el-input v-model="ruleForm.uMail" autocomplete="off" type="text" ></el-input>
    </el-form-item>
    <el-form-item label="真实姓名" prop="uName" type="text">
      <el-input v-model="ruleForm.uName"></el-input>
    </el-form-item>
    <el-form-item label="性别" prop="uSex">
      <el-select v-model="ruleForm.uSex" placeholder="请选择性别" style="right:400px">
        <el-option label="男" value=1></el-option>
        <el-option label="女" value=0></el-option>
      </el-select>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="submitForm('ruleForm')">修改</el-button>
    </el-form-item>
  </el-form>
    </el-main>
  </el-container>
</template>


<script>
  import Qs from 'qs';
    export default {
        name: "Information",
        data() {
            return {
                ruleForm: {
                   uAlias:'',
                    uMail:'',
                    uName:'',
                    uSex:'',
                  uTelephone:JSON.parse(sessionStorage.getItem('userinfo')).uTelephone
                },
        //       rules: {
        //         uAlias: [
        //           {required: true, message: '请输入正确手机号', trigger: 'blur'},
        //         ],
        //         uMail: [{required: true, message: '请邮箱', trigger: 'blur'}],
        //         uName: [{required: true, message: '请输入真实姓名', trigger: 'blur'}],
        //         uSex:  [{required: true, message: '请输入性别', trigger: 'blur'}],
        // }
              // <input class="easyui-validatebox" type="text" name="factorycode" id="factorycode" missingMessage="必须填写英文"  οnkeyup="value=value.replace(/[^a-zA-Z]/ig,'')" required="true" maxlength="10" οnkeydοwn="loadResult()"></input>
           }

      },
        methods: {
          submitForm(formName) {
               var user  = this.ruleForm;
               console.log(user);
                 this.axios({
                   method:'post',
                  url:'http://localhost:80/api/user/modify',
                  transformRequest: [function (data) {
                     return Qs.stringify(data)
                   }],
                  data:user
                }).then(function (res) {
                  console.log(res.data)
                  if (res.data.success) {
                    this.$router.push("/tomyinfor")
                  }
                }),
                   this.$message({
                   showClose: true,
                   type: 'success',
                   message: '修改成功!'
                 })
              }
         }
    }

</script>

<style scoped>
  .box1{
    border:1px solid #DCDFE6;
    box-shadow: 0px 0px 5px #DCDFE6;
    border-radius: 10px;
    width: 800px;
    height: 600px;
    margin-left: 180px;
    margin-top: 50px;
  }
  .demo-ruleForm{
    padding: 0px 50px 0px 10px;
  }


</style>
